﻿using System;
using System.Collections.Generic;

using System.Text;

namespace Efficient.Domain
{
    public delegate bool CompareAction<T>(T x, T y);
    public class GenericEqualityComparer<T> : IEqualityComparer<T>
    {
        private event CompareAction<T> compareAction;

        public GenericEqualityComparer(CompareAction<T> compareAction)
        {
            this.compareAction = compareAction;
        }

        public GenericEqualityComparer() { }

        #region IEqualityComparer<T> Members

        public bool Equals(T x, T y)
        {
            if (compareAction != null)
            {
                return compareAction(x, y);
            }
            return x.Equals(y);
        }

        public int GetHashCode(T obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
}
